package com.china.zhuoyue.ui.activity.commom

import android.content.Context
import com.china.zhuoyue.databinding.ActivityWebviewBinding
import com.china.zhuoyue.ui.base.BaseActivity
import com.china.zhuoyue.ui.ext.startActivityExt
import com.china.zhuoyue.ui.helper.InjectBundle
import com.china.zhuoyue.ui.viewmodel.ApplicationViewModel
import com.china.zhuoyue.ui.viewmodel.applicationViewModel

fun Context.openUrl(url: String) {
    startActivityExt<WebViewActivity> {
        putExtra(WebViewActivity.URL, url)
    }
}

class WebViewActivity : BaseActivity<ActivityWebviewBinding>() {
    private val mApplicationViewModel: ApplicationViewModel by applicationViewModel()

    companion object {
        const val URL = "url"
    }

    private val url: String by InjectBundle()
    override fun initView() {
        vb.webview.loadUrl(url)
    }

    override fun initData() {
        vb.webview.titleCangerListener = { vb.titleView.titleStr = it }
    }
}